﻿using System.Threading;
using System.Collections;
namespace System.Web
{
    public partial class NetHttpApplication
    {
        internal class AsyncAppEventHandlersTable
        {
            private Hashtable _table;

            internal void AddHandler(object eventId, BeginEventHandler beginHandler, EndEventHandler endHandler, object state, RequestNotification requestNotification, bool isPost, NetHttpApplication app)
            {
                if (_table == null)
                    _table = new Hashtable();
                var handler = (AsyncAppEventHandler)_table[eventId];
                if (handler == null)
                {
                    handler = new AsyncAppEventHandler();
                    _table[eventId] = handler;
                }
                handler.Add(beginHandler, endHandler, state);
                //if (HttpRuntime.UseIntegratedPipeline)
                //{
                //    var step = new AsyncEventExecutionStep(app, beginHandler, endHandler, state);
                //    app.AddEventMapping(app.CurrentModuleCollectionKey, requestNotification, isPost, step);
                //}
            }

            internal AsyncAppEventHandler this[object eventId]
            {
                get
                {
                    if (_table == null)
                        return null;
                    return (AsyncAppEventHandler)_table[eventId];
                }
            }
        }
    }
}
